const app = getApp();
const API_URL = app.globalData.API_URL;

Page({
  data: {
    customBar: app.globalData.CustomBar,
    ROOT_URL: app.globalData.ROOT_URL,
    deleteModal:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    let openid = wx.getStorageSync('openid');
    wx.request({
      url: API_URL+"getSeen",
      method:'POST',
      data:{'openid':openid},
      success(res){
        that.setData({
          favorList:res.data.data,
        })
      }
    })
  },

  showModal(e) {
    this.setData({
      deleteModal:true,
      delid:e.currentTarget.dataset.delid,
    })
  },
  hideModal(e) {
    this.setData({
      deleteModal: false
    })
  },

  deleteSeen(){
    let that = this;
    let id = this.data.delid;
    let openid = wx.getStorageSync('openid');
    wx.request({
      url: API_URL+"deleteSeen",
      method:'POST',
      data:{'openid':openid,'id':id},
      success(res){
        if(res.data.err==0){
          that.onShow();
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})